<?php
ob_start();
header('Content-Type: text/html;charset=utf-8');
/*
 * 分页数据
	更新记录：
		2015-05-13 创建
		2016-07-29 更新
*/
require '../../vendor/autoload.php';

use database\DBFolder;
use database\pager;
use utils\PathTool;
use utils\WebBase;

$wb = new WebBase();

$op		= $wb->queryString("op");
$id 	= $_GET["id"];

if(strcmp($op,"count") == 0)
{
	$count = DBFolder::count($id);
	$json = array('count' => $count);
	echo json_encode($json);
}
else
{
	$index	= $_GET["page"];
	
	if ( 	$id== ""
			||	$index==""
	)
	{
		header('HTTP/1.1 500 param is null');
		return;
	}
	
	$pg = new pager();
	$json = $pg->read($index, $id);
	$json = PathTool::url_encode($json);
	echo $json;
	header('Content-Length: ' . ob_get_length());
}
?>